home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagd_f.zip / FILES.SWG / 0038_Reading User-IDX Files.pas < prev    next >
Pascal/Delphi Source File  |  1993-11-02  |  9KB  |  240 lines

  1. {
  2.   Here's the demo Program I promised. You'll have to add the missing
  3.   Type definitions before you will be able to run this Program.
  4. }
  5.  
  6. Program Demo_Read_User_Files;
  7.  
  8. Type
  9.  
  10.   (* NOTE: Missing Type definitions need to go here, before this      *)
  11.   (*       Program will compile.                                      *)
  12.   (*                                                                  *)
  13.   (*   ie: uflags, suflags, acrq, mhireadr, mzscanr, fzscanr,         *)
  14.   (*       colors.                                                    *)
  15.   (*                                                                  *)
  16.  
  17.   (* USERS.IDX : Sorted names listing                     *)
  18.   UserIdxRec = Record
  19.     Name     : String[36];   (* Name (Real or handle) *)
  20.     Number   : Integer;      (* User number           *)
  21.     RealName : Boolean;      (* User's Real name?     *)
  22.     Deleted  : Boolean;      (* Deleted or not        *)
  23.     Left     : Integer;      (* Record or -1          *)
  24.     Right    : Integer;      (* Record or -1          *)
  25.   end;
  26.  
  27.   (* USERS.DAT : User Records                             *)
  28.   UserRec = Record
  29.     Name           : String[36];     (* System name      *)
  30.     RealName       : String[36];     (* Real name        *)
  31.     PW             : String[20];     (* PassWord         *)
  32.     Ph             : String[12];     (* Phone #          *)
  33.     BDay           : String[8];      (* Birthdate        *)
  34.     FirstOn        : String[8];      (* First on date    *)
  35.     LastOn         : String[8];      (* Last on date     *)
  36.     Street         : String[30];     (* Street address   *)
  37.     CityState      : String[30];     (* City, State      *)
  38.     ZipCode        : String[10];     (* Zipcode          *)
  39.  
  40.                                      (* Type of computer *)
  41.     UsrDefStr      : Array[1..3] of String[35];
  42.  
  43.     (* Occupation                                           *)
  44.  
  45.     (* BBS reference                                        *)
  46.     Note           : String[35];     (* SysOp note       *)
  47.     UserStartMenu  : String[8];      (* Menu to start at *)
  48.     LockedFile     : String[8];      (* Print lockout msg*)
  49.     Flags          : set of uflags;  (* Flags            *)
  50.     SFlags         : set of suflags; (* Status flags     *)
  51.     AR             : set of acrq;    (* AR flags         *)
  52.  
  53.                                      (* Voting data      *)
  54.     Vote           : Array[1..25] of Byte;
  55.  
  56.     Sex            : Char;           (* Gender           *)
  57.     TTimeOn,                         (* Total time on    *)
  58.     UK,                              (* UL k             *)
  59.     DK             : LongInt;        (* DL k             *)
  60.     TLToday,                         (* # Min left today *)
  61.     ForUsr,                          (* Forward mail to  *)
  62.     FilePoints     : Integer;        (* # Of File points *)
  63.  
  64.     UpLoads, DownLoads,              (* # Of ULs/# of DLs*)
  65.     LoggedOn,                        (* # Times on       *)
  66.     MsgPost,                         (* # Message posts  *)
  67.     EmailSent,                       (* # Email sent     *)
  68.     Feedback,                        (* # Feedback sent  *)
  69.     Timebank,                        (* # Mins in bank   *)
  70.     TimebankAdd,                     (* # Added today    *)
  71.     DlKToday,                        (* # KBytes dl today*)
  72.     DlToday        : Word;           (* # Files dl today *)
  73.  
  74.     Waiting,                         (* Mail waiting     *)
  75.     LineLen,                         (* Line length      *)
  76.     PageLen,                         (* Page length      *)
  77.     OnToday,                         (* # Times on today *)
  78.     Illegal,                         (* # Illegal logons *)
  79.     Barf,
  80.     LastMBase,                       (* # Last msg base  *)
  81.     LastFBase,                       (* # Last File base *)
  82.     SL, DSL        : Byte;           (* SL / DSL         *)
  83.  
  84.     (* Message last read date ptrs      *)
  85.     MHiRead         : mhireadr;
  86.     (* Which message bases to scan      *)
  87.     MzScan          : mzscanr;
  88.     (* Which File bases to scan         *)
  89.     FzScan          : fzscanr;
  90.  
  91.     (* User colors                      *)
  92.     Cols            : colors;
  93.  
  94.     Garbage         : Byte;
  95.  
  96.     (* Amount of time Withdrawn today   *)
  97.     TimebankWith    : Word;
  98.     (* Last day PassWord changed        *)
  99.     PassWordChanged : Word;
  100.     (* Default QWK archive Type         *)
  101.     DefArcType      : Byte;
  102.     (* Last conference they were in     *)
  103.     LastConf        : Char;
  104.     (* Date/time of last qwk packet     *)
  105.     LastQwk         : LongInt;
  106.     (* Add own messages to qwk packet?  *)
  107.     GetOwnQwk       : Boolean;
  108.     (* Scan File bases For qwk packets? *)
  109.     ScanFilesQwk    : Boolean;
  110.     (* Get private mail in qwk packets? *)
  111.     PrivateQwk      : Boolean;
  112.     (* Amount of credit a User has      *)
  113.     Credit          : LongInt;
  114.     (* Amount of debit a User has       *)
  115.     Debit           : LongInt;
  116.     (* Expiration date of this User     *)
  117.     Expiration      : LongInt;
  118.     (* Subscription level to expire to  *)
  119.     ExpireTo        : Char;
  120.     (* User's color scheme #            *)
  121.     ColorScheme     : Byte;
  122.     (* Echo Teleconf lines?             *)
  123.     TeleConfEcho    : Boolean;
  124.     (* Interrupt during typing?         *)
  125.     TeleConfInt     : Boolean;
  126.   end;
  127.  
  128.  
  129. (***** Check For IO error, and take some sort of action?            *)
  130. (*                                                                  *)
  131. Procedure CheckForIOerror;
  132. Var
  133.   in_Error : Integer;
  134. begin
  135.   in_Error := ioresult;
  136.   if (in_Error <> 0) then
  137.     begin
  138.       Writeln(' I/O Error = ', in_Error);
  139.  
  140.       (* Take some sort of action to correct error, or halt Program *)
  141.  
  142.     end
  143. end;        (* CheckForIOerror.                                     *)
  144.  
  145.  
  146. Var
  147.   rc_TempUI   : UserIdxRec;
  148.   rc_TempUR   : UserRec;
  149.  
  150.   fi_UsersIdx : File of UserIdxRec;
  151.   fi_UsersDat : File of UserRec;
  152.  
  153. begin
  154.               (* Open USERS.IDX File.                                 *)
  155.   assign(fi_UsersIdx, 'USERS.IDX');
  156.   {$I-}
  157.   reset(fi_UsersIdx);
  158.   {$I+}
  159.   CheckForIOerror;
  160.  
  161.               (* Read first Record from File.                         *)
  162.   read(fi_UsersIdx, rc_TempUI);
  163.   CheckForIOerror;
  164.  
  165.               (* Display data from the first Record.                  *)
  166.   With rc_TempUI do
  167.   begin
  168.     Writeln('Name      = ', Name);
  169.     Writeln('Number    = ', Number);
  170.     Writeln('Real Name = ', RealName);
  171.     Writeln('Deleted   = ', Deleted);
  172.     Writeln('Left      = ', Left);
  173.     Writeln('Right     = ', Right)
  174.   end;
  175.  
  176.               (* Read 10th Record from File.                          *)
  177.   seek(fi_UsersIdx, pred(10));
  178.   read(fi_UsersIdx, rc_TempUI);
  179.   CheckForIOerror;
  180.  
  181.               (* Display data from the 10th Record.                   *)
  182.   With rc_TempUI do
  183.   begin
  184.     Writeln('Name      = ', Name);
  185.     Writeln('Number    = ', Number);
  186.     Writeln('Real Name = ', RealName);
  187.     Writeln('Deleted   = ', Deleted);
  188.     Writeln('Left      = ', Left);
  189.     Writeln('Right     = ', Right)
  190.   end;
  191.  
  192.               (* Close USERS.IDX File.                                *)
  193.   close(fi_UsersIdx);
  194.   CheckForIOerror;
  195.  
  196.               (* Open USERS.DAT File.                                 *)
  197.   assign(fi_UsersDat, 'USERS.DAT');
  198.   {$I-}
  199.   reset(fi_UsersDat);
  200.   {$I+}
  201.   CheckForIOerror;
  202.  
  203.               (* Read first Record from File.                         *)
  204.   read(fi_UsersDat, rc_TempUR);
  205.   CheckForIOerror;
  206.  
  207.               (* Display data from the first Record.                  *)
  208.   With rc_TempUR do
  209.     begin
  210.       Writeln('Name      = ', Name);
  211.       Writeln('Real Name = ', RealName);
  212.       Writeln('Street    = ', Street);
  213.       Writeln('CityState = ', CityState);
  214.       Writeln('ZipCode   = ', ZipCode);
  215.       Writeln('Sex       = ', Sex)
  216.     end;
  217.  
  218.               (* Read 10th Record from File.                          *)
  219.   seek(fi_UsersDat, pred(10));
  220.   read(fi_UsersDat, rc_TempUR);
  221.   CheckForIOerror;
  222.  
  223.               (* Display data from the 10th Record.                   *)
  224.   With rc_TempUR do
  225.     begin
  226.       Writeln('Name      = ', Name);
  227.       Writeln('Real Name = ', RealName);
  228.       Writeln('Street    = ', Street);
  229.       Writeln('CityState = ', CityState);
  230.       Writeln('ZipCode   = ', ZipCode);
  231.       Writeln('Sex       = ', Sex)
  232.     end;
  233.  
  234.               (* Close USERS.DAT File.                                *)
  235.   close(fi_UsersDat);
  236.   CheckForIOerror;
  237.  
  238. end.
  239.  
  240.